#include <stdio.h>
#include <string.h>

int main()
{
    // 字符串初始化
    char str1[] = "Hello";
    char str2[] = "World";

    // 字符串长度
    printf("字符串长度: strlen(str1) = %lu\n", strlen(str1));

    // 字符串拼接
    char str3[100];
    strcpy(str3, str1);
    strcat(str3, " ");
    strcat(str3, str2);
    printf("字符串拼接: strcat(str3, str2) = %s\n", str3);

    // 字符串比较
    int cmp_result = strcmp(str1, str2);
    printf("字符串比较: strcmp(str1, str2) = %d\n", cmp_result);

    // 字符串查找
    char *found = strstr(str3, "World");
    if (found != NULL)
    {
        printf("字符串查找: strstr(str3, \"World\") = %s\n", found);
    }
    else
    {
        printf("字符串查找: strstr(str3, \"World\") = NULL\n");
    }

    // 字符串复制
    char str4[100];
    strcpy(str4, str1);
    printf("字符串复制: strcpy(str4, str1) = %s\n", str4);

    // 字符串替换
    char str5[] = "Hello World";
    char *replace = strstr(str5, "World");
    if (replace != NULL)
    {
        strcpy(replace, "Moonshot");
        printf("字符串替换: str5 = %s\n", str5);
    }

    // 字符串分割
    char str6[] = "apple,banana,orange";
    char *token = strtok(str6, ",");
    while (token != NULL)
    {
        printf("字符串分割: %s\n", token);
        token = strtok(NULL, ",");
    }

    return 0;
}